<?php
/* @var $this ReservationController */
/* @var $model Reservation */

$this->breadcrumbs=array(
	'Reservations'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List Reservation', 'url'=>array('index')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#reservation-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Reservations</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'afterAjaxUpdate' => 'reInstallDatepicker',
	'columns'=>array(
		array(      
			 'name'=>'customer_id',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'customer_id','FName'),
             'value'=>'reservation::Model()->FindByPk($data->id)->FName',
        ),
		array(      
			 'name'=>'service_id',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'service_id','service_id'),
             'value'=>'reservation::Model()->FindByPk($data->id)->service->type',
        ),
		array(
                        'name' => 'reservation_date',
                        'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                                'model' => $model, 
                                'attribute' => 'reservation_date',
								'language'=> 'en-AU',								
                                'options' => array( 
                                        'dateFormat' => 'yy-mm-dd',
                                        'showOtherMonths' => true,
                                        'selectOtherMonths' => true,
                                        'changeMonth' => true,
                                        'changeYear' => true,
                                ),
								'htmlOptions' => array(
                                        'id' => 'datepicker_for_reservation_date',
                                        'size' => '10',
                                )
                                
                        ), 
                        true),
                ),
		array(      
			 'name'=>'reservation_time',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'reservation_time','reservation_time'),
             'value'=>'reservation::Model()->FindByPk($data->id)->reservation_time',
        ),
		array(      
			 'name'=>'reservation_type',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'reservation_type','reservation_type'),
             'value'=>'reservation::Model()->FindByPk($data->id)->reservation_type',
        ),
		array(      
			 'name'=>'start_time',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'start_time','start_time'),
             'value'=>'reservation::Model()->FindByPk($data->id)->start_time',
        ),
		array(      
			 'name'=>'end_time',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'end_time','end_time'),
             'value'=>'reservation::Model()->FindByPk($data->id)->end_time',
        ),
		array(      
			 'name'=>'attendant_id',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'attendant_id','attendant_id'),
             'value'=>'reservation::Model()->FindByPk($data->id)->attendant->fname',
        ),
		array(      
			 'name'=>'bed_id',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'bed_id','bed_id'),
             'value'=>'reservation::Model()->FindByPk($data->id)->bed->bed_name',
        ),
		array(      
			 'name'=>'reservation_status',
             'filter'=>CHtml::listData(reservation::model()->findAll(array('order'=>'customer_id ASC')),'reservation_status','reservation_status'),
             'value'=>'reservation::Model()->FindByPk($data->id)->reservation_status',
        ),
		/*
		'create_at',
		*/
		array(
			'class'=>'CButtonColumn',
		),
	),
));
Yii::app()->clientScript->registerScript('for-date-picker',"
function reInstallDatepicker(id, data){
        $('#datepicker_for_some_date').datepicker();
}
"); ?>
